package cn.wolfcode.luowowo.website.web.controller;

import cn.wolfcode.luowowo.article.service.*;
import cn.wolfcode.luowowo.search.query.HotelSearchQuery;
import cn.wolfcode.luowowo.search.service.IHotelEsService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/hotel")
public class HotelController {

    @Reference
    private IHotelThemeService hotelThemeService;

    @Reference
    private IDestinationService destinationService;

    @Reference
    private IHotelService hotelService;

    @Reference
    private IRegion4HotelService region4HotelService;

    @Reference
    private IHotelEsService hotelEsService;

    @Reference
    private ICityRegionService cityRegionService;

    @RequestMapping("")
    public String index(Model model){
        model.addAttribute("list",region4HotelService.queryDestInRegion());
        model.addAttribute("hotelTags",hotelThemeService.queryThemes());
        model.addAttribute("hotelCity",hotelThemeService.queryDestsByThemeContent("特价酒店"));
        return "hotel/hotel";
    }

    @RequestMapping("/theme")
    public String getTheme(Model model,Long id){
        model.addAttribute("list", hotelThemeService.queryDestsByThemeId(id));
        return "hotel/hotelTpl";
    }

    @RequestMapping("/hotelOnSale")
    public String hotelOnSale(Model model,Long destId){
        model.addAttribute("hotels",hotelService.queryHotelsOnSale(destId));
        return "hotel/hotelTpl1";
    }

    @RequestMapping("/booking")
    public String hotelBooking(Model model, @ModelAttribute("qo") HotelSearchQuery qo){
        model.addAttribute("cityRegions",cityRegionService.queryByDestId(qo.getDestId()));
//        model.addAttribute("hotel",hotelEsService.findByDestName(qo.getName()));
        return "hotel/dingjiudian";
    }

    @RequestMapping("/h")
    public String page(Model model,@ModelAttribute("qo") HotelSearchQuery qo){
        model.addAttribute("page",hotelEsService.query(qo));
        return "hotel/hotelListTpl";
    }

}